﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace QuanLyBilliards_Coffee
{
    public class XuLyChuoiVao
    {
        public static string CatKhoangTrangDu(string input)
        {
            string pattern = @"\s{2,}";
            return Regex.Replace(input, pattern, delegate(Match m)
            {
                if (m.Index == 0 || m.Index == input.Length)
                    return "";
                else
                    return " ";
            });
        }
        public static bool KiemTraSDT(string s)
        {
            string pattern = @"^0([1-9]{1})\d{8,9}";
            Regex rg = new Regex(pattern, RegexOptions.IgnoreCase);
            if (!rg.IsMatch(s))
            {

                return false;
            }
            return true;
        }
        public static bool KiemTraSo(string s)
        {
            string pattern = @"[0-9]";
            Regex rg = new Regex(pattern, RegexOptions.IgnoreCase);
            if (!rg.IsMatch(s))
            {
                return false;
            }
            return true;
        }
        public static bool KiemTraChuoiRong(string s)
        {
            if (CatKhoangTrangDu(s) == "")
                return false;
            return true;
        }
    }
}
